<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<script>
	var ctx = "${ctx}";
</script>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>我的广告管理</title>
<meta name="keywords" content="">
<meta name="description" content="">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
<meta http-equiv="expires" content="Wed, 26 Feb 209908:21:57 GMT">

<link href="${ctx}/static/css/bootstrap.min.css?v=${static_version}"
	rel="stylesheet" />
<link
	href="${ctx}/static/css/font-awesome.min.css?v=4.4.0?v=${static_version}"
	rel="stylesheet" />
<link href="${ctx}/static/css/animate.min.css?v=${static_version}"
	rel="stylesheet" />
<link href="${ctx}/static/css/style.min.css?v=${static_version}"
	rel="stylesheet" />
<link href="${ctx}/static/css/common.css" rel="stylesheet" />
<!-- Data Tables -->
<link
	href="${ctx}/static/css/plugins/dataTables/dataTables.bootstrap.css?v=${static_version}"
	rel="stylesheet" />

</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content  animated fadeInRight">
		<div class="ibox float-e-margins">


			<!-- 我的广告列表 -->
			<div class="ibox-title">
				<h5>
					我的广告列表<small></small>
				</h5>
				
				<a class="btn btn-refresh" style="display:none" onclick="javascript:location.replace(location.href);" href="javascript:location.replace(location.href);" title="刷新">刷新</a>
			</div>

			<div class="ibox-content">
				<table
					class="table table-striped table-bordered table-hover dataTables-example">
					<thead>
						<tr>
							<th class="text-center" data-sort-ignore="true"
								data-title="people_limit">位置</th>
							<th class="text-center" data-sort-ignore="true"
								data-title="title">缩略图</th>
							<th class="text-center" data-sort-ignore="true"
								data-title="add_time">跳转URL</th>
							<th class="text-center" data-sort-ignore="true"
								data-title="people_limit">投放金额</th>
							<th class="text-center" data-sort-ignore="true"
								data-title="begin_time">投放剩余时间</th>
							<th class="text-center" data-sort-ignore="true"
								data-title="status">支付状态</th>
							<th class="text-center" data-sort-ignore="true"
								data-title="status">广告状态</th>
							<th class="text-center">操作</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${advertList}" var="advert">
							<tr class="footable-even" style="display: table-row;">
								<td class="footable-visible">${advert.position_name}</td>
								<td class="footable-visible footable-first-column text-center"><img
									alt="image" src="${advert.covers}" style="height: 100px;"></td>
								<td class="footable-visible">${advert.detail_url}</td>
								<td class="footable-visible">${advert.total_amount}</td>
								<td class="footable-visible"><c:choose>
										<c:when test="${advert.remainday<=0}">
													已到期
												</c:when>
										<c:otherwise>
													${advert.remainday}
												</c:otherwise>
									</c:choose></td>
								<td class="footable-visible"><c:choose>
										<c:when test="${advert.is_pay==0}">
													未支付
												</c:when>
										<c:otherwise>
													已支付
												</c:otherwise>
									</c:choose></td>
								<td class="footable-visible"><c:choose>
										<c:when test="${advert.status==0}">
													等待审核
												</c:when>
										<c:when test="${advert.status==1}">
													开放
												</c:when>
										<c:when test="${advert.status==2}">
													关闭
												</c:when>
										<c:otherwise>
													审核未通过
												</c:otherwise>
									</c:choose></td>
								<td class="text-center footable-visible footable-last-column"><c:choose>
										<c:when test="${advert.is_pay==0}">
											<a class="btn btn-warning"
												href="${ctx}/toadvertpay?advertid=${advert.id}" title="支付">支付</a>
											<br />
										</c:when>
									</c:choose> <a class="btn btn-warning"
									onClick="u_advert_edit(this,'${advert.id}')"
									href="javascript:void(0);" title="编辑">编辑</a> <br /> <a
									class="btn btn-danger"
									onClick="u_advert_delete(this,'${advert.id}')"
									href="javascript:void(0);" title="删除">删除</a></td>
							</tr>
						</c:forEach>
					</tbody>
				</table>

				<div class="row">
					<div class="col-md-6" class="pull-left" id="page_left_text"></div>
					<div class="col-md-6" id="page_text"></div>
				</div>
			</div>
		</div>
	</div>

	<script src="${ctx}/static/js/jquery.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/bootstrap.min.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/js/plugins/layer/layer.js?v=${static_version}"></script>

	<!-- 插件脚本 -->
	<script
		src="${ctx}/static/js/plugins/dataTables/jquery.dataTables.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/js/plugins/dataTables/dataTables.bootstrap.js?v=${static_version}"></script>
	
	<script type="text/javascript">
	
		$(document).ready(function() {
			$(".dataTables-example").dataTable();
		});

		/*编辑*/
		function u_advert_edit(obj, id) {
			var index = layer.open({
				type : 2,
				title : '位置广告编辑',
				shadeClose : true,
				shade : 0.8,
				content : "${ctx}/advert_positionadvert-addOrUpdate?id=" + id
			});
			layer.full(index);
		}

		/*软删除*/
		function u_advert_delete(obj, id) {
			layer.confirm('确认删除？', {
				btn : [ '确认', '取消' ],
				shade : false
			}, function() {
				$.ajax({
					type : "POST",
					url : "${ctx}/u_advert-delete",
					data : "advertid=" + id,
					error : function() {
						layer.msg('操作失败', {
							icon : 5,
							time : 1000
						});
					},
					success : function(msg) {
						layer.msg('已删除 ' + msg.information, {
							icon : 6,
							time : 1000
						});
						location.reload();
					}
				});
			}, function() {
				layer.msg('未删除', {
					icon : 5,
					time : 1000
				});
			});
		}
	</script>
</body>
</html>